package edu.asu.cse360.service.impl;

import edu.asu.cse360.annotation.TargetEntity;
import edu.asu.cse360.dao.DataAccessObject;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.springframework.beans.factory.annotation.Autowired;

import edu.asu.cse360.dto.ImageDto;
import edu.asu.cse360.model.Restaurant;
import edu.asu.cse360.service.RestaurantService;
import org.springframework.stereotype.Service;

@Service("restaurantService")
public class RestaurantServiceImpl implements RestaurantService{

	@Autowired
        @TargetEntity(Restaurant.class)
	private DataAccessObject<Restaurant, Integer> restaurantDao;
	
    @Override
    public Restaurant findById(Integer id) {
            System.out.println("Remote Find By Id");
            Restaurant res = new Restaurant();
            res.setId(id);
            //Restaurant res2 = dao.read(id);
            //System.out.println(res2);
            System.out.println("End Remote Find by Id");
            return res;
    }

    public void saveImage(ImageDto inputDto) {
            BufferedImage input = inputDto.getImage();
            File file = new File("./output.jpg");
            try {
                    ImageIO.write(input, "jpg", file);
            } catch (IOException e) {
                    e.printStackTrace();
            }
    }

}
